Add support for OIDC ID token authentication using an environment variables and files#445
Conversation
databricks-sdk-java/src/main/java/com/databricks/sdk/core/oauth/FileIDTokenSource.java
Outdated
Show resolved
Hide resolved
databricks-sdk-java/src/main/java/com/databricks/sdk/core/oauth/FileIDTokenSource.java
Outdated
Show resolved
Hide resolved
databricks-sdk-java/src/main/java/com/databricks/sdk/core/oauth/FileIDTokenSource.java
Outdated
Show resolved
Hide resolved
databricks-sdk-java/src/main/java/com/databricks/sdk/core/oauth/EnvVarIDTokenSource.java
Show resolved
Hide resolved
databricks-sdk-java/src/main/java/com/databricks/sdk/core/DefaultCredentialsProvider.java
Outdated
Show resolved
Hide resolved
databricks-sdk-java/src/main/java/com/databricks/sdk/core/oauth/EnvVarIDTokenSource.java
Outdated
Show resolved
Hide resolved
databricks-sdk-java/src/main/java/com/databricks/sdk/core/oauth/EnvVarIDTokenSource.java
Show resolved
Hide resolved
databricks-sdk-java/src/main/java/com/databricks/sdk/core/oauth/FileIDTokenSource.java
Outdated
Show resolved
Hide resolved
databricks-sdk-java/src/main/java/com/databricks/sdk/core/oauth/FileIDTokenSource.java
Show resolved
Hide resolved
parthban-db
left a comment
There was a problem hiding this comment.
Overall looks good. Few small comments.
| // Test case name, file path (null means create temp file), file content, expected token, | ||
| // expected exception | ||
| Arguments.of("Valid token file", null, TEST_TOKEN, TEST_TOKEN, null), | ||
| Arguments.of("Token with whitespace", null, " " + TEST_TOKEN + " ", TEST_TOKEN, null), | ||
| Arguments.of("Empty file", null, "", null, DatabricksException.class), | ||
| Arguments.of("File with only whitespace", null, " ", null, DatabricksException.class), | ||
| Arguments.of("Null file path", null, null, null, IllegalArgumentException.class), |
There was a problem hiding this comment.
I am not sure I understand this correctly. What are you trying to test in the Null file path because it will create the file anyway.
There was a problem hiding this comment.
The file is only created if the file content is not null, so in cases where the content is null, no file will be created. But I agree that the previous logic was a bit convoluted, so I’ve refactored the tests to make them more straightforward and intuitive.
databricks-sdk-java/src/test/java/com/databricks/sdk/core/oauth/FileIDTokenSourceTest.java
Outdated
Show resolved
Hide resolved
databricks-sdk-java/src/test/java/com/databricks/sdk/core/oauth/FileIDTokenSourceTest.java
Show resolved
Hide resolved
databricks-sdk-java/src/main/java/com/databricks/sdk/core/oauth/EnvVarIDTokenSource.java
Outdated
Show resolved
Hide resolved
databricks-sdk-java/src/main/java/com/databricks/sdk/core/oauth/FileIDTokenSource.java
Outdated
Show resolved
Hide resolved
|
If integration tests don't run automatically, an authorized user can run them manually by following the instructions below: Trigger: Inputs:
Checks will be approved automatically on success. |
renaudhartert-db
left a comment
There was a problem hiding this comment.
LGTM! Thanks Emmy
What changes are proposed in this pull request?
Add Environment Variable and File-based ID Token Sources
Key Changes
EnvVarIDTokenSourceto read ID tokens from environment variablesFileIDTokenSourceto read ID tokens from filesIDTokenSourceinterface for OIDC authenticationHow is this tested?
NO_CHANGELOG=true